using System.Collections;
using System.Collections.Generic;
using UnityEngine;

public class SlimeHitState : EnemyState
{
    Enemy_Slime enemy;
    public SlimeHitState(Enemy enemyBase, EnemyStateMachine enemyStateMachine, string animatorName, Enemy_Slime enemy) : base(enemyBase, enemyStateMachine, animatorName)
    {
        this.enemy = enemy;
    }

    public override void Enter()
    {
        base.Enter();
        stateTimer = enemy.knockBackTime;
        rb.velocity = new Vector2(enemy.knockDir * enemy.knockBackPower.x, enemy.knockBackPower.y);
    }

    public override void Exit()
    {
        base.Exit();
        enemy.stat.SetWuDi(false);
    }

    public override void Update()
    {
        base.Update();
        if(rb.velocity.y<.1f&&enemy.isGround())
        {
            enemy.stat.SetWuDi(true);
            enemy.animator.SetTrigger("HitFond");
        }
        if (stateTimer < 0)
            enemyStateMachine.ChangeState(enemy.slimeIdleState);
    }
}
